#ifndef __FG__SINGLETON__H__
#define __FG__SINGLETON__H__
namespace FragrantGrass
{
	template <class T>
	class Singleton
	{

	public:

		Singleton()
		{
			m_pInstance = static_cast<T*>(this);
		}

		virtual ~Singleton()
		{
			m_pInstance = nullptr;
		}

	public:

		static T* Instance()
		{
			if (nullptr == m_pInstance)
			{
				m_pInstance = new T;
			}

			return m_pInstance;
		}

		static void Release()
		{
			delete m_pInstance;
			m_pInstance = nullptr;
		}

	private:
		static T* m_pInstance;
	};

	template <class T>
	T* Singleton<T>::m_pInstance = nullptr;
}
#endif//__FG__SINGLETON__H__